<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>p2_CSS选择器</title>
    <style>
        h4{
            color:red;
        }
        div{
            width: 100px;
            height: 100px;
            background-color: yellow;
        }
        #h2{
            background-color: yellow;
        }
        .error{
            background-color: red;
        }
        .success{
            background-color: green;
        }
        .msg{
            color: white;
        }
        #h2,.error,p{
            border: 5px solid purple;
        }
        *{
            font-style: italic;
        }
        input[type="text"]{
            background-color: cyan;
        }
        #d1:hover{
            background-color: purple;
        }
        /*伪类选择器:link:visited:hover:active*/
        a:link{
            color:gray;
        }
        a:visited{
            color:green;
        }
        a:hover{
            color: orange;
        }
        a:active{
            color: red;
        }
        #d2 span{
            background-color: blue;
        }
        #d2>div>span{
            color:red;
        }
    </style>
</head>
<body>
    <div id="d2">
        <span>111</span>
        <div>
            <span>222</span>
            <p>测试文字</p>
            <p>我是 <span>测试</span>段落</p>
        </div>
        <span>333</span>
    </div>
    <hr>
    <h4>我是标题</h4>
    <p>我是段落</p>
    <a href="#">我是超链接</a>
    <h4 id="h2">我是标题2</h4>
    <div id="d1">我是div1</div>
    <div>我是div2</div>
    <div>我是div3</div>
    <br>
    <span class="error msg">用户名不能为空</span>
    <span class="error msg">密码不能为空</span>
    <span class="success msg">用户名格式正确</span>
    <span class="success msg">密码格式正确</span>
    <hr>
    <input type="text">
    <input type="password">
    <hr>
    <a href="https://www.baidu.com">超链接1</a>
    <a href="abc">超链接2</a>
</body>
</html>